import { defineStore } from 'pinia'
import { reactive } from 'vue'
import { childrenType } from '@/components/library/list.vue'
export type listType = {
  title: string,
  key: number,
  children: childrenType[]
}
const fileStore = defineStore('file', () => {
  const fileList = reactive<listType[]>([{
    title: 'test',
    key: 2014505,
    children: [{
      name: 'test',
      key: 2555551,
      path: 'D:\/code\/electron-vue\/electron_vue\/electron\/data\/test.json'
    },
    {
      name: 'test',
      key: 2555553,
      path: 'D:\/code\/electron-vue\/electron_vue\/electron\/data\/test.json'
    },
    {
      name: 'test',
      key: 2555554,
      path: 'D:\/code\/electron-vue\/electron_vue\/electron\/data\/test.json'
    }]
  }])
  const fileHistory = reactive([])
  const currentFileInfo = reactive({})
  function thoroughDelete() {

  }
  function addFile(newItem: listType[], index: number = fileList.length) {
    // const newIndex = index ? index : fileList.length
    fileList.splice(index, 0, ...newItem)
  }
  return { fileList, fileHistory, currentFileInfo, addFile }
})
export default fileStore